from django.conf.urls import url
from django.contrib import admin
from rest_framework_jwt.views import obtain_jwt_token
from .views import statistical, users, specs, images, skus,orders
from rest_framework.routers import DefaultRouter

urlpatterns = [
    # 登录
    url(r'^authorizations/$', obtain_jwt_token),
    # 用户总量
    url(r'^statistical/total_count/$', statistical.UserCount.as_view()),
    # 日增用户
    url(r'^statistical/day_increment/$', statistical.UserDayCount.as_view()),
    # 日活用户
    url(r'^statistical/day_active/$', statistical.UserDayActiveCount.as_view()),
    url(r'^statistical/day_orders/$', statistical.UserDayOrderCount.as_view()),
    url(r'^statistical/month_increment/$', statistical.UserMonthCount.as_view()),
    url(r'^statistical/goods_day_views/$', statistical.GoodsVisitCountView.as_view()),
    # 用户管理
    url(r'^users/$', users.UserView.as_view()),
    # 规格表路由
    url(r'^goods/simple/$', specs.SpecsView.as_view({'get': 'simple'})),
    # 图片路由
    url(r'^skus/simple/$', images.ImageView.as_view({'get': 'simple'})),
    # 　ｓｋｕ路由
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),

]

# 规格表路由
rotuer = DefaultRouter()
rotuer.register('goods/specs', specs.SpecsView, base_name='specs')
urlpatterns += rotuer.urls
# 图片路由
rotuer = DefaultRouter()
rotuer.register('skus/images', images.ImageView, base_name='specs')
urlpatterns += rotuer.urls
# sku路由
rotuer = DefaultRouter()
rotuer.register('skus', skus.SKUView, base_name='skus')
print(rotuer.urls)
urlpatterns += rotuer.urls


# 订单路由
rotuer = DefaultRouter()
rotuer.register('orders', orders.OrderView, base_name='orders')
print(rotuer.urls)
urlpatterns += rotuer.urls